import request from '@/utils/request'
import { start, end } from '@/utils/time'
// 搜索售货机(售货机列表)
export const getVendingList = (params) => {
  return request({
    url: '/api/vm-service/vm/search',
    params
  })
}

// 获设备详情销售量
export const getGoodsCount = (id) => {
  return request({
    url: '/api/order-service/report/orderCount',
    params: {
      innerCode: id,
      start: start() + ' 00:00:00',
      end: end() + ' 23:59:59'
    }
  })
}

// 设备详情销售额
export const getGoodsMoney = (id) => {
  return request({
    url: '/api/order-service/report/orderAmount',
    params: {
      innerCode: id,
      start: start() + ' 00:00:00',
      end: end() + ' 23:59:59'
    }
  })
}

// 获取售货机维修次数
export const getRepairCount = (id) => {
  return request({
    url: `/api/task-service/task/repairCount/${id}/${start()}/${end()}`
  })
}

// 获取售货机补货次数
export const getSupplyCount = (id) => {
  return request({
    url: `/api/task-service/task/supplyCount/${id}/${start()}/${end()}`
  })
}

// 获取售货机商品销量
export const getSkuCollect = (id) => {
  return request({
    url: `/api/order-service/report/skuCollect/${id}/${start()}/${end()}`
  })
}

// 售货机类型列表(搜索)
export const getTypeList = (params) => {
  return request({
    url: '/api/vm-service/vmType/search',
    params
  })
}

// 新增售货机类型
export const getAddType = (data) => {
  return request({
    method: 'post',
    url: '/api/vm-service/vmType',
    data
  })
}

// 获取售货机类型详情
export const getTypeDetail = (typeId) => {
  return request({
    url: '/api/vm-service/vmType/' + typeId
  })
}

// 修改售货机类型
export const editTypeDetail = (typeId, data) => {
  return request({
    method: 'put',
    url: '/api/vm-service/vmType/' + typeId,
    data
  })
}

// 设备管理型号选择
export const getVmTypeSelect = (params) => {
  return request({
    url: '/api/vm-service/vmType/search',
    params
  })
}

// 设备管理点位选择
export const getVmNodeSelect = (params) => {
  return request({
    url: '/api/vm-service/node/search',
    params
  })
}

// 设备增加
export const addEquipment = (data) => {
  return request({
    method: 'post',
    url: '/api/vm-service/vm',
    data
  })
}

// 选择策略
export const selectPolicy = () => {
  return request({
    url: '/api/vm-service/policy'
  })
}

// 应用策略
export const applyPolicy = (data) => {
  return request({
    method: 'put',
    url: '/api/vm-service/vm/applyPolicy',
    data
  })
}

// 查询售货机策略
export const getVmPolicy = (id) => {
  return request({
    url: '/api/vm-service/policy/vmPolicy/' + id
  })
}

// 取消策略
export const cancelPolicy = (innerCode, policyId) => {
  return request({
    method: 'put',
    url: `/api/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`
  })
}

// 修改售货机点位
export const changeNode = (id, nodeId) => {
  return request({
    method: 'put',
    url: `/api/vm-service/vm/${id}/${nodeId}`
  })
}

// 获取售货机货道详情
export const getChannelList = (innerCode) => {
  return request({
    url: '/api/vm-service/channel/channelList/' + innerCode
  })
}

// 添加饮料
export const getDrinklList = (params) => {
  return request({
    url: '/api/vm-service/sku/search',
    params
  })
}

// 获取商圈下销量前10的商品(补货推荐)
export const getTop10Drinks = (businessId) => {
  return request({
    url: '/api/vm-service/sku/businessTop10/' + businessId
  })
}

// 商圈列表
export const getBusinessType = (businessId) => {
  return request({
    url: '/api/vm-service/businessType/name/' + businessId
  })
}

// 货道配置
export const getChannelConfig = (data) => {
  return request({
    method: 'put',
    url: '/api/vm-service/channel/channelConfig',
    data
  })
}
